package com.mapper;

import com.entity.CalendarEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.sql.Date;
import java.util.List;

@Repository
public interface CalendarMapper {

    @Select("SELECT * FROM canlendar")
    @Results({
            @Result(property = "id",  column = "id", javaType = Integer.class),
            @Result(property = "date",  column = "date" ),
            @Result(property = "year", column = "year"),
            @Result(property = "day", column = "day"),
            @Result(property = "isweekday", column = "isweekday")
    })
    List<CalendarEntity> getAll();

    @Select("SELECT * FROM canlendar WHERE id = #{id}")
    @Results({
            @Result(property = "date",  column = "date"),
            @Result(property = "year", column = "year"),
            @Result(property = "month", column = "month"),
            @Result(property = "day", column = "day"),
            @Result(property = "isweekday", column = "isweekday")
    })
    CalendarEntity getOneById(int id);

    @Select("SELECT count(1) FROM canlendar WHERE month = #{month} and isweekday ='true'")
    int getWeekDayCountByMonth(String month);

    @Insert("INSERT INTO canlendar(date,year,month,day,isweekday) VALUES(#{date}, #{year}, #{month},#{day},#{isweekday})")
    void insert(CalendarEntity calendar);
//
//    @Update("UPDATE users SET userName=#{userName},nickName=#{nickName} WHERE id =#{id}")
//    void update(UserEntity user);
//
//    @Delete("DELETE FROM users WHERE id =#{id}")
//    void delete(Long id);

}